<?php

$api = app('Dingo\Api\Routing\Router');
$moduleName = 'Code';

// 平台后台api
$api->version('v1', ['prefix' => 'admin-api', 'namespace' => 'Modules\\'.$moduleName.'\Http\Controllers\Admin\V1'], function ($api) {
	$allMethod = ['index', 'show', 'store', 'update', 'destroy'] ;

	$api->post('/codes/batch', ['uses'=> "CodeController@batchCreate"]);
	$api->resource('codes', "CodeController", ['only' => $allMethod]);
	$api->resource('code-records', "CodeRecordController", ['only' => $allMethod]);

	$api->post('/export/codes', ['uses'=> "CodeExportController@store"]);
	$api->post('/export/code-total', ['uses'=> "CodeExportController@total"]);
	$api->get('/export/codes/{uuid}', ['uses'=> "CodeExportController@show"]);
});

// 租户api
$api->version('v1', ['prefix' => 'tenant-api', 'namespace' => 'Modules\\'.$moduleName.'\Http\Controllers\Tenant\V1'], function ($api) {
	$allMethod = ['index', 'show', 'store', 'update', 'destroy'];
});

// 普通用户api
$api->version('v1', ['namespace' => 'Modules\\'.$moduleName.'\Http\Controllers\Client\V1'], function ($api) {
	$allMethod = ['index', 'show', 'store', 'update', 'destroy'];

	$api->post('/code/check', ['uses'=> "CodeController@check"]);
	$api->post('/code/use', ['uses'=> "CodeController@use"]);

	$api->get('/code-records', ['uses'=> "CodeRecordController@index"]);
});